var Action = require("../apiaction");
var Utility = require("../Utility/utility.js");
exports.budgetAPI = function(router){

    //*******房屋类型
    //列表获取
    router.all('/budget/getHouseTypeList', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/getHouseTypeList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //******单位管理

    //列表获取
    router.all('/budget/getUnitListPaging', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/getUnitListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/budget/addUnit', function (req, res) {

        var params = {name: req.param("name")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/addUnit", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/budget/deleteUnit', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/deleteUnit", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //材料种类
    //列表获取
    router.all('/budget/GetMaterialTypeList', function (req, res) {

        var params = {select_flag:req.param("select_flag")};
        params = Utility.get_list_page_size_param(req, params);

        //console.log(params);

        Action.send(req, res, "/budget/GetMaterialTypeList", params, function (res, data) {


            res.status(200).json(JSON.parse(data));
        });
    });

    //材料
    //列表获取
    router.all('/budget/getMaterialListPaging', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/getMaterialListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/budget/addMaterial', function (req, res) {

        var params = {name: req.param("name"),remark: req.param("remark"),ratio: req.param("ratio"),formula: req.param("formula"),type_id: req.param("type_id"),unit_id: req.param("unit_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/addMaterial", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/budget/deleteMaterial', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/deleteMaterial", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //案例
    //列表获取
    router.all('/budget/getBudgetCaseListPaging', function (req, res) {

        var params = {worker_id: req.param("worker_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/getBudgetCaseListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //案例详情列表获取
    router.all('/budget/getDetailListPaging', function (req, res) {

        var params = {case_id: req.param("case_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/budget/getDetailListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });




}